package com.wtzz.police.base.model.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 权限
 *
 * @author zxh
 * @date 2019-04-16
 */
@Getter
public enum Role {
    USER("普通用户"), ADMIN("管理员");

    private String desc;

    Role(String desc) {
        this.desc = desc;
    }

    @JsonCreator
    public static Role fromDesc(String desc) {
        for (Role role : Role.values()) {
            if (role.getDesc().equals(desc)) {
                return role;
            }
        }
        return null;
    }

    @JsonValue
    public String toDesc() {
        return getDesc();
    }
}
